<template>
  <div class="recommend">
    <headers>
      <span slot="title">人气推荐</span>
    </headers>

    <ul class="shoplist">
      <li v-for="item in shoplist" :key="item.id" @click="gotorecommend_list(item.id)">
        <img :src="item.pic">
        <p style="font-size:12px;margin-top:1vh" class="txt">{{item.name}}</p>
        <p class="characteristic">{{item.characteristic}}</p>
        <p class="price">{{'￥'+item.maxCoupons}}</p>
      </li>
    </ul>

  </div>
</template>
<script>
  import headers from '../../components/headers.vue'
  export default {
    components: {
      headers
    },
    data() {
      return {
        shoplist: []
      }
    },

    methods: {
      gotorecommend_list(id){
        // console.log(id);
        this.$router.push({path : this.$path.RECOMMEND_LIST,query:{id}})
      }
    },

    mounted() {
      this.$API.shop_list().then((res) => {
        // console.log(res);
        this.shoplist = res.data.data

      }).catch((err) => {
        console.log(err);
      });
    }

  }
</script>

<style lang="scss" scoped>
  .recommend {
    width: 100vw;
    height: 100%;
    display: flex;
    flex-flow: column;
  }

  .shoplist {
    flex: 1;
    overflow: scroll;
    height: 80vh;
    display: flex;
    flex-flow: wrap;
    justify-content: space-evenly;
    justify-items: center;

    li {
      margin-top: 1vh;
      width: 46vw;
      height: 48%;
      background-color: #fff;

      img {
        width: 100%;
        height: 72%;

      }

      .txt {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap
      }

      .characteristic {
        font-size: 12px;
        margin-top: 1vh;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        color: #ccc;
      }

      .price {
        color: red;
        font-size: 12px;
        margin-top: 1vh;
      }
    }
  }
</style>